from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import os

key = os.urandom(16)
iv = os.urandom(16)

# 加密（CFB模式，段大小=128位）
cipher = AES.new(key, AES.MODE_CFB, iv=iv, segment_size=128)
plaintext = b"Hello World"  # 11字节 → 需填充到16字节

ciphertext = cipher.encrypt(plaintext)

# 解密
cipher = AES.new(key, AES.MODE_CFB, iv=iv, segment_size=128)
decrypted_padded = cipher.decrypt(ciphertext)

print(decrypted_padded.decode())  # 输出: Hello World